<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>虚拟时钟系统</title>
		<link rel="stylesheet" href="../demo.css" />
		<script type="text/javascript" src="../../com.mofum.jade.config.engine.js" ></script>
	</head>
	<body>
		
		<div class="text-info">
			<p><h1>虚拟时钟系统</h1></p>
			<p>
				虚拟时钟系统作为引擎的核心部分，主要用于驱动时间运转，它就是一个动态世界的燃料。当时间停止，
				整个游戏就停止了。
			</p>
			<p>
				JadeGrid 引擎的设计核心就是围绕着时间开展的。一切事件的触发皆由时间直接或者间接触发。让游戏开发者
				更加简单进行开发游戏。
			</p>
		</div>
		<hr/>
		<div id = "show">
			<p>虚拟世界秒: <span id="mssecond">0</span> (ms);</p>
			<p>虚拟世界秒: <span id="second">0</span> (s);</p>
			<p>虚拟世界分: <span id="minute">0</span> (m);</p>
			<p>虚拟世界时: <span id="hour">0</span> (h);</p>
			<p>虚拟世界日: <span id="day">0</span> (d);</p>
			<p>虚拟世界月: <span id="month">0</span> (M);</p>
			<p>虚拟世界年: <span id="year">0</span> (y);</p>
			<p>虚拟世界季节: <span id="sesson">春</span> (S);</p>
			
			<p><span>秒单位</span> <input type="number" id="msecond2" />(毫秒)</p>
			<p><span>分单位</span> <input type="number" id="second2" />(秒钟)</p>
			<p><span>小时单位</span> <input type="number" id="minute2" />(分钟)</p>
			<p><span>天单位</span> <input type="number" id="hour2" />(小时)</p>
			<p><span>2月闰年单位</span> <input type="number" id="day2r" />(天)</p>
			<p><span>2月平年单位</span> <input type="number" id="day2" />(天)</p>
			<p><span>大月单位</span> <input type="number" id="month2b" />(天)</p>
			<p><span>小月单位</span> <input type="number" id="month2s" />(天)</p>
			<p><span>闰年单位</span> <input type="number" id="year2r" />(天)</p>
			<p><span>平年单位</span> <input type="number" id="year2" />(天)</p>
			<p><span>春季开始月</span> <input type="number" id="springStart" />(月)</p>
			<p><span>春季周期</span> <input type="number" id="spring" />(月)</p>
			<p><span>夏季周期</span> <input type="number" id="summer" />(月)</p>
			<p><span>秋季周期</span> <input type="number" id="autumn" />(月)</p>
			<p><span>冬季周期</span> <input type="number" id="winter" />(月)</p>
			<button id="submit"> 提交</button>
			<button id="start">开始</button>
			<button id="stop">停止</button>
			<button id="suspend">暂停</button>
			<button id="resume">恢复</button>
		</div>
		<hr/>
		<a href="#" onClick="javascript :history.back(-1);">返回上一页</a>
		<script>
			var world = new JadeEngine.World();
//			world.getClock().timeUnit.CONST_MILLISECOND_TO_SECOND = 1;
//			world.getClock().timeUnit.CONST_SECOND_TO_MINUTE = 1;
//			world.getClock().timeUnit.CONST_MINUTE_TO_HOUR = 1;
//			world.getClock().timeUnit.CONST_HOUR_TO_DAY = 1;
//			world.getClock().timeUnit.CONST_DAY_TO_LARGE_MONTH = 2;
//			world.getClock().timeUnit.CONST_DAY_TO_SMALL_MONTH = 2;
//			world.getClock().timeUnit.CONST_DAY_TO_LEAP_YEAR_FEBRUARY = 2;
//			world.getClock().timeUnit.CONST_DAY_TO_YEAR_FEBRUARY = 2;
//			world.getClock().timeUnit.CONST_DAY_TO_LEAP_YEAR = 24;
//			world.getClock().timeUnit.CONST_DAY_TO_YEAR = 24;
			world.setTimeCallBack(function(type,value){
				if(JadeEngine.Toolkit.TimeUnit.CONST_MILLISECOND == type){
					document.getElementById("mssecond").innerHTML = value;
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_SECOND == type){
					document.getElementById("second").innerHTML = value;
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_MINUTE == type){
					document.getElementById("minute").innerHTML = value;
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_HOUR == type){
					document.getElementById("hour").innerHTML = value;
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_DAY == type){
					document.getElementById("day").innerHTML = value+1;
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_MONTH == type){
					document.getElementById("month").innerHTML = value+1;
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_YEAR == type){
					document.getElementById("year").innerHTML = value+1;
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_SEASON_SPRING == type){
					document.getElementById("sesson").innerHTML = "春";
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_SEASON_SUMMER == type){
					document.getElementById("sesson").innerHTML = "夏";
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_SEASON_AUTUMN == type){
					document.getElementById("sesson").innerHTML = "秋";
				}
				if(JadeEngine.Toolkit.TimeUnit.CONST_SEASON_WINTER == type){
					document.getElementById("sesson").innerHTML = "冬";
				}
			});
			
			document.getElementById("msecond2").value = world.getClock().timeUnit.CONST_MILLISECOND_TO_SECOND;
			document.getElementById("second2").value = world.getClock().timeUnit.CONST_SECOND_TO_MINUTE;
			document.getElementById("minute2").value = world.getClock().timeUnit.CONST_MINUTE_TO_HOUR;
			document.getElementById("hour2").value = world.getClock().timeUnit.CONST_HOUR_TO_DAY;
			document.getElementById("day2r").value = world.getClock().timeUnit.CONST_DAY_TO_LEAP_YEAR_FEBRUARY;
			document.getElementById("day2").value = world.getClock().timeUnit.CONST_DAY_TO_YEAR_FEBRUARY ;
			document.getElementById("month2b").value = world.getClock().timeUnit.CONST_DAY_TO_LARGE_MONTH;
			document.getElementById("month2s").value = world.getClock().timeUnit.CONST_DAY_TO_SMALL_MONTH;
			document.getElementById("year2r").value = world.getClock().timeUnit.CONST_DAY_TO_LEAP_YEAR;
			document.getElementById("year2").value = world.getClock().timeUnit.CONST_DAY_TO_YEAR;
			document.getElementById("springStart").value = world.getClock().timeUnit.CONST_SEASON_START_MONTH -1;
			document.getElementById("spring").value = world.getClock().timeUnit.CONST_SPRING_TO_SUMMER;
			document.getElementById("summer").value = world.getClock().timeUnit.CONST_SUMMER_TO_AUTUMN;
			document.getElementById("autumn").value = world.getClock().timeUnit.CONST_AUTUMN_TO_WINTER;
			document.getElementById("winter").value = world.getClock().timeUnit.CONST_WINTER_TO_SPRING;
			
			document.getElementById("submit").onclick = function(){
				world.getClock().timeUnit.CONST_MILLISECOND_TO_SECOND = document.getElementById("msecond2").value-0;
				world.getClock().timeUnit.CONST_SECOND_TO_MINUTE = document.getElementById("second2").value-0;
				world.getClock().timeUnit.CONST_MINUTE_TO_HOUR = document.getElementById("minute2").value-0;
				world.getClock().timeUnit.CONST_HOUR_TO_DAY = document.getElementById("hour2").value-0;
				world.getClock().timeUnit.CONST_DAY_TO_LEAP_YEAR_FEBRUARY = document.getElementById("day2r").value-0;
				world.getClock().timeUnit.CONST_DAY_TO_YEAR_FEBRUARY = document.getElementById("day2").value-0;
				world.getClock().timeUnit.CONST_DAY_TO_LARGE_MONTH = document.getElementById("month2b").value-0;
				world.getClock().timeUnit.CONST_DAY_TO_SMALL_MONTH = document.getElementById("month2s").value-0;
				world.getClock().timeUnit.CONST_DAY_TO_LEAP_YEAR = document.getElementById("year2r").value-0;
				world.getClock().timeUnit.CONST_DAY_TO_YEAR = document.getElementById("year2").value-0;
				world.getClock().timeUnit.CONST_SEASON_START_MONTH = document.getElementById("springStart").value-0+1;
				world.getClock().timeUnit.CONST_SPRING_TO_SUMMER = document.getElementById("spring").value-0;
				world.getClock().timeUnit.CONST_SUMMER_TO_AUTUMN = document.getElementById("summer").value-0;
				world.getClock().timeUnit.CONST_AUTUMN_TO_WINTER = document.getElementById("autumn").value-0;
				world.getClock().timeUnit.CONST_WINTER_TO_SPRING =  document.getElementById("winter").value-0;
			}
			
			document.getElementById("start").onclick = function(){
				world.start();
			}
			document.getElementById("stop").onclick = function(){
				world.stop();
			}
			document.getElementById("suspend").onclick = function(){
				world.suspend();
			}
			document.getElementById("resume").onclick = function(){
				world.resume();
			}
		</script>
		
	</body>
</html>
